package com.example.qjia.Presenters;

import com.example.qjia.Listener.LoadHolidayMessageListener;
import com.example.qjia.data.HolidayMessage;
import com.example.qjia.data.romotedata.AbsenceSlip;
import com.example.qjia.model.LoadHolidayMessageModel;
import com.example.qjia.model.LoadHolidayMessageModelImp;
import com.example.qjia.ui.ViewInterface.DetailHolidayMessageInterface;

/**
 * Created by ying_xiang on 2016/8/16.
 */
public class DetailHolidayMessagePresenterImp implements DetailHolidayMessagePresenter,LoadHolidayMessageListener {


    private LoadHolidayMessageModel loadHolidayMessageModel;
    private DetailHolidayMessageInterface detailHolidayMessageInterface;

    public DetailHolidayMessagePresenterImp(DetailHolidayMessageInterface detailHolidayMessageInterface) {
        this.detailHolidayMessageInterface = detailHolidayMessageInterface;
        loadHolidayMessageModel=new LoadHolidayMessageModelImp();
    }

    @Override
    public void loadHolidayMessage(String aid) {
        detailHolidayMessageInterface.showProgressBar();
        loadHolidayMessageModel.loadHolidayMessage(aid,this);

    }

    @Override
    public void destroy() {
        detailHolidayMessageInterface=null;
        loadHolidayMessageModel=null;

    }

    @Override
    public void backTomain() {
        detailHolidayMessageInterface.backToMain();

    }

    @Override
    public void goToMap() {
        detailHolidayMessageInterface.goToBimap();

    }

    @Override
    public void onSuccess(AbsenceSlip holidayMessage) {

        detailHolidayMessageInterface.hideProgressBar();
        System.out.println(holidayMessage.toString());
        detailHolidayMessageInterface.setHolidayMessage(holidayMessage);

    }

    @Override
    public void onFail() {
        detailHolidayMessageInterface.hideProgressBar();
        detailHolidayMessageInterface.errorReload();

    }
}
